class Solution:
    def singleNumber(self, nums: list) -> int:
        mid_dic = {}
        for i in nums:
            if i in mid_dic:
                continue
            num = nums.count(i)
            if num == 1:
                return i
            mid_dic[i] = num


class Solution2:
    def singleNumber(self, nums: list) -> int:
        mid_set = set()
        for i in nums:
            if i in mid_set:
                continue
            num = nums.count(i)
            if num == 1:
                return i
            mid_set.add(i)

class Solution3:
    def singleNumber(self, nums: list) -> int:
        a, b = 0, 0
        for num in nums:
            b = ~a & (b ^ num)
            a = ~b & (a ^ num)
        return b


a = Solution3()
print(a.singleNumber([0, 1, 0, 1, 0, 1, 99]))